package com.zhiwen.test;

/**
 * @Auther: wuzhiwen
 * @Date: 2018/12/18 14:59
 * @Description:
 */
public class InsertionSort {
    public static void main(String[] args) {
        int[] arr = {49, 38, 65, 97, 76, 13, 27, 49, 78, 34, 12, 64, 1};
        int preIndex, current;
        int len = arr.length;
        for (int i = 0; i < len; i++) {
            preIndex = i - 1;
            current = arr[i];
            while (preIndex >= 0 && arr[preIndex] > current) {
                arr[preIndex + 1] = arr[preIndex];
                preIndex--;
            }
            arr[preIndex + 1] = current;
        }
        for (int i = 0; i < arr.length; i++) {
            System.out.println(i+"");
        }
    }
}
